home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / cp1.zip / DFREE3.C < prev    next >
Text File  |  1993-04-30  |  3KB  |  81 lines

  1. ===========================================================================
  2.  BBS: The Abacus * HST/DS * Potterville MI
  3. Date: 04-27-93 (17:22)             Number: 244
  4. From: HENRY PIPER                  Refer#: 283
  5.   To: CHRIS DOWNS                   Recvd: NO  
  6. Subj: get disk free space            Conf: (36) C Language
  7. ---------------------------------------------------------------------------
  8.           Chris Downs wrote 
  9.  +-------------------------------+
  10. ###How can I get the amount of free space on a hard disk?  I tried calling DO
  11. ###with function 1B.  But that (or the code afterwards) sent the program into
  12. ###never never land.  Could someone please provide a helpful little snippet?
  13. ###Thanks,
  14. ###
  15. ###--- GEcho 1.00
  16. ### * Origin: Kevin's Place [314-739-0571] (1:100/215)
  17.  +-------------------------------+
  18. One snippet comming up, this is for Any Borland compiler, or Power C.
  19. #include <stdio.h>
  20. #include <ctype.h>
  21. #include <dos.h>
  22. #include <string.h>
  23. #include <process.h>
  24.  
  25. main(int argc, char *argv[])
  26. {
  27.     static char drivestr[5];
  28.     char tempstr[5];
  29.     static int drivenum;
  30.     long bytes_avail, bytes_total;
  31.     struct dfree data;
  32.     if (argc > 2)
  33.     { printf("Wrong number of arguments entered.");
  34.       exit(1);
  35.     }
  36.  
  37.     if(argc == 2)
  38.     {
  39.         strcpy(tempstr, argv[1]);
  40.         strupr(tempstr);
  41.         strcpy(drivestr, tempstr);
  42.     }
  43.     if (strcmp(drivestr,"A:")==0)
  44.     { printf("\n We are checking drive A:\n");
  45.       drivenum = 1;
  46.        }
  47.     if (strcmp(drivestr,"B:")==0)
  48.      { printf("\nWe are checking drive B:\n");
  49.        drivenum = 2;
  50.        }
  51.     if (strcmp(drivestr,"C:")==0)
  52.     { printf("\nWe are checking drive C:\n");
  53.       drivenum = 3;
  54.       }
  55.     if (argc < 2)
  56.     { printf("\nWe are checking the default drive.\n");
  57.       drivenum = 0;
  58.       }
  59.     getdfree(drivenum,&data);
  60.     if (data.df_sclus != 0xFFFF)
  61.         {
  62.             bytes_avail = (long) data.df_avail * data.df_bsec * data.df_sclus;
  63.             bytes_total = (long) data.df_total * data.df_bsec * data.df_sclus;
  64.             printf ("%lu Bytes Available out of a Total of %lu\n",bytes_avail,b
  65.          }
  66.     else printf("Bad data read");
  67. }
  68.  
  69.  
  70.  
  71.  * TLX v2.20 * The race from stupidity is to the driven, not the swift.
  72.  
  73.  * SLMR 2.1 *
  74.  
  75.  
  76. --- WM v2.07/91-0077
  77.  * Origin: The Boardwalk! - (206) 941-3124 - Federal Way, WA (1:343/47)
  78. SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
  79. SEEN-BY: 153/752 154/40 77 157/2 159/100 125 575 950 203/23 209/209 280/1
  80. SEEN-BY: 390/1 396/1 5 15 2270/1 2440/5 3603/20
  81.